<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->helper('file');
        $this->load->helper('fuc');
        $this->load->library('topclass');
        $this->load->library('session_db');
        $this->load->model("auth_handle");
        $this->load->model("users");
        $this->load->database();
        $this->config->load('topapiconfig');
    }

    public function actlogin() {
        
		if( !isset($_GET["top_sign"])) redirect('login/index', 'location', 301);
		
		$sign = $this->auth_handle->login_gettopsession();
        $top_sign = $_GET["top_sign"];

        if ($sign != $top_sign) {
            echo "签名错误";
            //跳转链接
            redirect('login/index', 'location', 301);
            exit();
        } else {
            $this->users->user_process(); //登陆授权成功对user表处理 
            $this->session_db->write_Sessiondb("statue", "login");   //如果登陆赋予session状态；
            $this->session_db->write_Sessiondb("last_active_time", time());  //写入最新登陆时间为了做topsession判定
            redirect('home/index', 'location', 301);
        }

        exit;
    }

    public function index() {

        $data['menu'] = 'index';
		$data['user'] = array();
        $this->load->view('header_view', $data);
        $this->load->view('login_view');
        $this->load->view('footer_view');
    }

    public function logout() {

        $this->auth_handle->logout_action();
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */